(deftemplate employee 
	(slot salary) (slot name)
)

(watch all)

(defrule test-accumulate
	?c <- ( accumulate 
				(bind ?count 0)								;Initializer
				(bind ?count (+ ?count 1))					;Action
				?count										;Result to return
				(employee (salary ?s&: (> ?s 10000)))		;CE
			
		  )
		=>
		(printout t ?c " is the employees with salaries greater than 10000" crlf)
)

(defrule test-accumulate-addToList
	?c <- ( accumulate 
				(bind ?list (new java.util.ArrayList))							;Initializer
				(?list add ?name)												;Action
				?list															;Result to return
				(employee 
					(salary ?s&: (> ?s 10000))
					(name ?name)
				)																;CE
			
		  )
		=>
		(printout t (?c toString) crlf)
)

(reset)

(assert 
	(employee 
		(salary 100000) (name ajit)
	)
)

(assert 
	(employee 
		(salary 100010) (name skanda)
	)
)

(assert 
	(employee 
		(salary 100020) (name ram)
	)
)

(facts)

(rules)

(list-deftemplates)

(list-focus-stack)

(run)
